from socket import *
from time import ctime

HOST = ''
PORT = 21569
BUFSIZ = 1024
ADDR = (HOST, PORT)

tcpServSock = socket(AF_INET, SOCK_STREAM)
tcpServSock.bind(ADDR)
tcpServSock.listen(5)

print('waiting for connection...')
tcpClientSock, addr = tcpServSock.accept()
print('...connected from: ', addr)

while True:
    data = str(tcpClientSock.recv(BUFSIZ))
    if not data:
        break
    ret_data = '[%s]%s' % (ctime(), data)
    print(ret_data)
    tcpClientSock.send(bytes(ret_data))

tcpClientSock.close()
tcpServSock.close()
